<!--教师管理员报名管理页面-->
<template>
    <div>
        <div style="display: flex;align-items: center;justify-content: center">
            <el-input style="width: 150px" placeholder="查询名称" v-model="name" clearable></el-input>

            <el-button type="primary" style="margin-left: 10px" @click="load(1)">查询</el-button>
            <el-button type="info" @click="reset" plain>重置</el-button>
        </div>

        <el-table :data="tableData"
                  stripe
                  :header-cell-style="{ backgroundColor: 'aliceblue', color: '#666'}"
                  style="font-size: 14px; margin-top: 20px"
        >
            <el-table-column width="50" align="center"></el-table-column>
            <el-table-column prop="name" label="竞赛名称" align="center"></el-table-column>
            <el-table-column prop="payNo" label="支付流水号" align="center"></el-table-column>
            <el-table-column prop="money" label="支付金额" align="center"></el-table-column>
            <el-table-column prop="buyer" label="购买人" align="center"></el-table-column>
            <el-table-column prop="payTime" label="支付时间" align="center"></el-table-column>

        </el-table>
        <div style="margin: 10px 0; display: flex; align-items: center; justify-content: center">
            <el-pagination
                    @current-change="handleCurrentChange"
                    :current-page="pageNum"
                    :page-size="pageSize"
                    layout="total, prev, pager, next"
                    :total="total">
            </el-pagination>
        </div>
    </div>
</template>

<script>
    import request from "@/utils/request";

    export default {
        name: "Pay",
        data() {
            return {
                tableData: [], //所有的数据
                pageNum: 1, //当前的页码
                pageSize: 6, //每页显示的个数
                name: '',
                total: 0, //默认是0
                user: JSON.parse(localStorage.getItem("honey-user") || '{}'),//拿取个人用户信息
            }
        },
        created() {
            this.load()
        },
        methods: {
            reset() { //重置
                this.name = ''
                this.load()
            },
            load(pageNum) { //分页查询
                if (pageNum) {
                    this.pageNum = pageNum
                }
                this.$request.get('/pay/selectByUserPage', {
                    params: {
                        pageNum: this.pageNum,
                        pageSize: this.pageSize,
                        name: this.name,
                    }
                }).then(res => {
                    this.tableData = res.data.records
                    console.log(this.tableData)
                    this.total = res.data.total
                })
            },
            handleCurrentChange(pageNum) {
                this.load(pageNum)
            },
        }
    }

</script>

<style>

</style>